import request from '@/utils/request'

const baseUrl = "http://localhost:9528/api/"
const accountPath = "account/"
const authPath = "auth/"
const sysPath = "sys/"
const rolePath = "role/"
const orgPath = "org/"

export function captcha() {
  return request({url: baseUrl + 'captcha', method: 'get'})
}

export function login(data) {
  return request({url: baseUrl + 'login', method: 'post', data})
}

export function logout() {
  return request({url: baseUrl + 'logout', method: 'post'})
}

/******** 用户 *********/
/***** 账号 *******/
export function accountInfo() {
  return request({url: baseUrl + accountPath + 'info', method: 'get'})
}

export function accounts() {
  return request({url: baseUrl + accountPath + 'list/', method: 'get'})
}

export function addAccount(data) {
  return request({url: baseUrl + accountPath + 'add', method: 'post', data})
}

export function updateAccount(data) {
  return request({url: baseUrl + accountPath + 'update/', method: 'post'})
}

export function delAccount(id) {
  return request({url: baseUrl + accountPath + 'del/' + id, method: 'post'})
}

/******** 权限 *********/
/***** 获取所有权限（树形结构） *******/
export function auths(sysCode) {
  return request({url: baseUrl + authPath + 'list/' + sysCode, method: 'get'})
}

export function saveAuth(data) {
  return request({url: baseUrl + authPath + 'save', method: 'post', data})
}

export function delAuth(authId) {
  return request({url: baseUrl + authPath + 'del/' + authId, method: 'post'})
}

export function getAuth(authId) {
  return request({url: baseUrl + authPath + 'auth/' + authId, method: 'get'})
}

/***** 权限 - 系统 *******/
export function sys() {
  return request({url: baseUrl + sysPath + 'list', method: 'get'})
}

export function addSys(data) {
  return request({url: baseUrl + sysPath + 'add', method: 'post', data})
}

export function updateSysStatus(id, op) {
  return request({url: baseUrl + sysPath + op + '/' + id, method: 'post'})
}

export function delSys(code) {
  return request({url: baseUrl + sysPath + 'del/' + code, method: 'post'})
}

/***** 权限 - 角色 *******/
export function list(parameter) {
  return request({url: baseUrl + rolePath + 'list', method: 'get', parameter})
}

export function roles(parameter) {
  return request({url: baseUrl + rolePath + 'roles', method: 'get', parameter})
}

export function addRole(data) {
  return request({url: baseUrl + rolePath + 'add', method: 'post', data})
}

export function saveRole(data) {
  return request({url: baseUrl + rolePath + 'save/', method: 'post', data})
}

export function updateRoleStatus(id, op) {
  return request({url: baseUrl + rolePath + op + '/' + id, method: 'post'})
}

export function delRole(id) {
  return request({url: baseUrl + rolePath + 'del/' + id, method: 'post'})
}
/***** 权限 - 单位 *******/
export function treeOrg(parameter) {
  return request({url: baseUrl + orgPath + 'tree', method: 'get', parameter})
}

export function saveOrg(data) {
  return request({url: baseUrl + orgPath + 'save', method: 'post', data})
}

export function updateOrgStatus(id, op) {
  return request({url: baseUrl + orgPath + op + '/' + id, method: 'post'})
}

export function delOrg(id) {
  return request({url: baseUrl + orgPath + 'del/' + id, method: 'post'})
}
